load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild")
load("//tools:defaults.bzl", "ts_project", "tsec_test")

package(default_visibility = ["//visibility:public"])

ts_project(
    name = "event-dispatch",
    srcs = glob(
        [
            "**/*.ts",
        ],
    ),
    deps = [
        "//packages/core/src/util",  # Implicit dependency on ngDevMode
    ],
)

tsec_test(
    name = "tsec_test",
    target = ":event-dispatch",
    tsconfig = "//packages/core:tsconfig_build",
)

filegroup(
    name = "files_for_docgen",
    srcs = glob([
        "*.ts",
        "src/**/*.ts",
    ]),
    visibility = ["//visibility:public"],
)

esbuild(
    name = "contract_bundle_min",
    config = {
        "resolveExtensions": [
            ".mjs",
            ".js",
        ],
        "legalComments": "none",
    },
    entry_point = ":contract_binary.js",
    format = "iife",
    minify = True,
    sourcemap = "external",
    deps = [":event-dispatch"],
)
